<?php

namespace app\plugin\controller\shop;

use app\BaseController;
use app\plugin\model\shop\Shop as ShopModel;
use think\Exception;

class Shop extends BaseController
{
    public function index()
    {
        return view();
    }

    public function list()
    {
        try {
            $shop  = new ShopModel();
            $limit = input('limit', 10);
            $shops = $shop->paginate($limit);
            foreach ($shops as $shop){
                $shop->column_name = '';
                if($shop->column){
                    $shop->column_name = $shop->column->name;
                }
                $shop->pay_date = '';
                if($shop->pay_start || $shop->pay_end){
                    $shop->pay_date = $shop->pay_start.'~'.$shop->pay_end;
                }
            }
            return lay_data($shops);
        } catch (Exception $e) {
            return lay_data(false, $e->getMessage());
        }
    }
}